using UnityEngine;

namespace ZCUtil.Factory
{
    #region Enum
    /// <summary>
    /// Mesh枚举
    /// </summary>
    public enum eMeshType
    {
        ZC_QUAD,
    };
    #endregion

    /// <summary>
    /// 网格生产类
    /// </summary>
    public class MeshFactory
    {
        #region PublicMethod
        public static Mesh GetMesh(eMeshType meshType)
        {
            Mesh result = null;
            switch (meshType)
            {
                case eMeshType.ZC_QUAD:
                    result = GetQuadMesh();
                    break;
                default:
                    break;
            }
            return result;
        }
        #endregion

        #region PrivateMethod
        private static Mesh GetQuadMesh()
        {
            Mesh mesh = new Mesh();
            mesh.vertices = new Vector3[]{
                new Vector3(-1, -1, 0),
                new Vector3(-1,  1, 0),
                new Vector3( 1,  1, 0),
                new Vector3( 1, -1, 0)
            };
            mesh.uv = new Vector2[] {
                new Vector2(0, 0),
                new Vector2(0, 1),
                new Vector2(1, 1),
                new Vector2(1, 0),
            };
            mesh.SetIndices(new int[] { 0, 1, 2, 2, 3, 0 }, MeshTopology.Triangles, 0);
            return mesh;
        }
        #endregion
    }
}